package com.imooc.course.file.controller;

import com.imooc.course.server.dto.ResponseDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerExceptionHandler {

    private static final Logger log = LoggerFactory.getLogger(ControllerExceptionHandler.class);

    @ExceptionHandler(value = RuntimeException.class)
    @ResponseBody
    public ResponseDto handlerRuntimeException(RuntimeException re) {
        log.error("异常信息:"+re.toString(),re);
        return ResponseDto.fail().setMsg("内部异常！");
    }

}
